﻿var fileuploaded;
//alert(filelen);
var millisecondsToWait = 5000;

function uploadResumecomplete(sender, args) {
    var filelen = args.get_length();
    //alert(filelen);

    if (filelen > 102400) {

        $("#ctl00_MainContent_lblResumeUploadStatus").css("color", "red");
        $("#ctl00_MainContent_lblResumeUploadStatus").show();
        $("#ctl00_MainContent_lblResumeUploadStatus").text("File size can not be more than 100kb");

        //$("#ctl00_MainContent_lblResumeUploadStatus").fadeOut(9000);
        //setTimeout(function () {
        //    $("#ctl00_MainContent_lblResumeUploadStatus").text("");
        //    $("#ctl00_MainContent_lblResumeUploadStatus").empty();

        //}, millisecondsToWait);

        $("#ctl00_MainContent_uploadedResumeLink").hide();
        $("#ctl00_MainContent_uplProUploadResume").hide();


        return false;
    }

    fileuploaded = args.get_fileName();

    //alert('resume' + fileuploaded);
    $.ajax({
        type: "post",
        url: "EditProfile.aspx/LoadResumeOnComplete",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: true,
        success: function (data) {
            if (data.d.length > 0) {
                //alert('resume ' + data.d);
                $("#ctl00_MainContent_uploadedResumeLink").attr("href", data.d);
            }
        },
        error: function (xmlHttpRequest, textStatus, errorThrown) {
            alert(xmlHttpRequest.responseText);
            alert(textStatus);
            alert(errorThrown);
        }
    });
    $("#ctl00_MainContent_lblResumeUploadStatus").css("color", "green");
    $("#ctl00_MainContent_lblResumeUploadStatus").text("Resume uploaded successfully");

    $("#ctl00_MainContent_uploadedResumeLink").show();
    $("#ctl00_MainContent_uplProUploadResume").hide();


    //$("#ctl00_MainContent_lblResumeUploadStatus").fadeOut(9000);
    //setTimeout(function () {
    //    $("#ctl00_MainContent_lblResumeUploadStatus").text("");
    //    $("#ctl00_MainContent_lblResumeUploadStatus").empty();

    //}, millisecondsToWait);


}
function uploadResumeStart(sender, args) {

    var filename = args.get_fileName();
    var filext = filename.substring(filename.lastIndexOf(".") + 1);
    if (filext == "doc" || filext == "pdf" || filext == "Pdf" || filext == "PDF" || filext == "docx" || filext == "doc") {

        $("#ctl00_MainContent_lblResumeUploadStatus").show();
        $("#ctl00_MainContent_uplProUploadResume").show();

        return true;
    }
    else {
        var err = new Error();
        err.message = "Only .pdf,.PDF,.docx,doc  files are allowed";
        $("#ctl00_MainContent_lblResumeUploadStatus").show();

        $("#ctl00_MainContent_uplProUploadResume").hide();
        $("#ctl00_MainContent_uploadedResumeLink").hide();

        throw (err);
        return ;
    }
}
function uploadResumeError(sender, args) {
    //alert(args.get_errorMessage());
    $("#ctl00_MainContent_lblResumeUploadStatus").css("color", "red");
    $("#ctl00_MainContent_lblResumeUploadStatus").show();
    $("#ctl00_MainContent_lblResumeUploadStatus").text(args.get_errorMessage());


    //$("#ctl00_MainContent_lblResumeUploadStatus").fadeOut(9000);
    //setTimeout(function () {
    //    $("#ctl00_MainContent_lblResumeUploadStatus").text("");
    //    $("#ctl00_MainContent_lblResumeUploadStatus").empty();

    //}, millisecondsToWait);
    $("#ctl00_MainContent_uploadedResumeLink").hide();

}